#include <iostream>
#include <string>
#include <sstream>
#include "Priority_Queue.h"

using namespace std;

int main()
{
    srand(time(NULL));

    int N;

    cout << "Input the number of monsters: ";
    cin >> N;
    int M_Blood_Limit = 30;

    vector<DataBase<string, int>> Monsters(N);
    for (int i = 0; i < N; i++)
    {
        ostringstream name;
        name << "Monster" << i;
        Monsters[i].key = name.str();
        Monsters[i].data = (rand() % M_Blood_Limit) + 1;
        // cout << Monsters[i].key << " , " << Monsters[i].data << endl;
    }

    PriorityQueue<string, int> Monster_Queue(Monsters);

    int cnt = 0;
    while (!Monster_Queue.isEmpty())
    {
        cnt++;
        int damage = rand() % 21 - 5;
        DataBase<string, int> target = Monster_Queue.findMin();
        Monster_Queue.modifyData(target.key, -damage);
        target.data -= damage;
        if (target.data <= 0)
        {

            Monster_Queue.remove(target.key);
            cout << target.key << " was killed." << endl;
        }
        else
        {
            cout << target.key << "'HP " << (damage <= 0 ? "+" : "")
                 << -damage << " , HP left : " << target.data << endl;
        }

        if (cnt > 0 && cnt % 4 == 0)
        {
            int random = rand() % N;
            ostringstream name;
            name << "Monster" << random;
            cout << "Spell to " << name.str() << endl;
            Monster_Queue.remove(name.str());
        }
    }
}